import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  // 统一存数据的地方
  state () {
    return {
      loginStatus: '用户已经登录',
      count: 0
    }
  },
  // 类似计算属性
  getters: {
  },
  mutations: {
    changeCount (state, num) {
      state.count += num
      console.log('changeCount is run', state.count)
    }
  },
  actions: {
    delayChangeCount (store, num) {
      store.commit('changeCount')
    }
  },
  modules: {
  }
})
